home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / keyboard-configuration.postinst < prev    next >
Encoding:
Text File  |  2013-01-05  |  3.6 KB  |  146 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. # Source debconf library.
  6. . /usr/share/debconf/confmodule
  7.  
  8. # The same as /usr/bin/which - in order to make "which" available before
  9. # /usr is mounted
  10. which () {
  11.     local IFS
  12.     IFS=:
  13.     for i in $PATH; do
  14.     if [ -x "$i/$1" ]; then
  15.         echo "$i/$1"
  16.         return 0
  17.     fi
  18.     done
  19.     return 1
  20. }
  21.  
  22. # In d-i the config script is not executed automatically
  23. if [ -f /usr/share/console-setup/keyboard-configuration.config ]; then
  24.     /usr/share/console-setup/keyboard-configuration.config || exit $?
  25. fi
  26.  
  27.  
  28.  
  29. keyboard_present () {
  30.     local kern kbdpattern class subclass protocol
  31.  
  32.     kern=`uname -r`
  33.     case "$kern" in
  34.     1*|2.0*|2.1*|2.2*|2.3*|2.4*|2.5*)
  35.         # can't check keyboard presence
  36.         return 0; 
  37.         ;;
  38.     esac
  39.  
  40.     [ -f /proc/bus/input/devices ] || return 0
  41.     kbdpattern="AT Set \|AT Translated Set\|AT Raw Set"
  42.     kbdpattern="$kbdpattern\|Atari Keyboard"
  43.     kbdpattern="$kbdpattern\|Amiga Keyboard"
  44.     kbdpattern="$kbdpattern\|HIL keyboard"
  45.     kbdpattern="$kbdpattern\|ADB keyboard"
  46.     kbdpattern="$kbdpattern\|Sun Type"
  47.     if grep -i "$kbdpattern" /proc/bus/input/devices >/dev/null; then
  48.     return 0
  49.     fi
  50.  
  51.     [ -d /sys/bus/usb/devices ] || return 0
  52.     for d in /sys/bus/usb/devices/*:*; do
  53.     class=$(cat "$d/bInterfaceClass") # 03 = Human Interface Device
  54.     subclass=$(cat "$d/bInterfaceSubClass") # 01 = Boot Interface Subclass
  55.     protocol=$(cat "$d/bInterfaceProtocol") # 01 = Keyboard
  56.     case "$class:$subclass:$protocol" in
  57.         03:01:01)
  58.         return 0
  59.         ;;
  60.     esac
  61.     done
  62.  
  63.     return 1
  64. }
  65.  
  66. # keyboard_present () {
  67. #     if there is a keyboard; then
  68. #     return 0
  69. #     else
  70. #     return 1
  71. #     fi
  72. # }
  73.  
  74. CONFIGFILE=/etc/default/keyboard
  75.  
  76. if [ "$1" = "configure" -a ! -L "$CONFIGFILE" ]; then
  77.     
  78.     db_get keyboard-configuration/modelcode
  79.     model="$RET"
  80.  
  81.     db_get keyboard-configuration/layoutcode
  82.     layout="$RET"
  83.  
  84.     db_get keyboard-configuration/variantcode
  85.     variant="$RET"
  86.  
  87.     db_get keyboard-configuration/optionscode
  88.     options="$RET"
  89.  
  90.     if [ ! -e $CONFIGFILE ]; then
  91.     cat /usr/share/console-setup/keyboard \
  92.         2>/dev/null >$CONFIGFILE || true
  93.     fi
  94.  
  95.     # Ensure we do not mess up the config file's ownership and permissions.
  96.     cp -a -f $CONFIGFILE $CONFIGFILE.tmp
  97.  
  98.     # If the admin deleted or commented some variables but then set
  99.     # them via debconf, (re-)add them to the conffile.
  100.     for var in XKBMODEL XKBLAYOUT XKBVARIANT XKBOPTIONS BACKSPACE; do
  101.         if ! grep "^ *${var}=" $CONFIGFILE >/dev/null; then
  102.         echo "${var}=" >>$CONFIGFILE
  103.     fi
  104.     done    
  105.     
  106.     sed \
  107.     -e "s|^ *XKBMODEL=.*|XKBMODEL=\"$model\"|" \
  108.     -e "s|^ *XKBLAYOUT=.*|XKBLAYOUT=\"$layout\"|" \
  109.     -e "s|^ *XKBVARIANT=.*|XKBVARIANT=\"$variant\"|" \
  110.     -e "s|^ *XKBOPTIONS=.*|XKBOPTIONS=\"$options\"|" \
  111.     -e "s|^ *BACKSPACE=.*|BACKSPACE=\"${BACKSPACE:-guess}\"|" \
  112.     <$CONFIGFILE >$CONFIGFILE.tmp
  113.     
  114.     mv -f $CONFIGFILE.tmp $CONFIGFILE
  115.  
  116.     db_set keyboard-configuration/store_defaults_in_debconf_db true
  117. fi
  118.  
  119. if \
  120.     [ -d /lib/debian-installer.d ] && keyboard_present
  121. then
  122.     if [ "$DISPLAY" ] && which setxkbmap >/dev/null; then
  123.     setxkbmap -option '' -model "$model" "$layout" "$variant" "$options"
  124.     else
  125.     OS=`udpkg --print-os`
  126.     if [ "$OS" = hurd ]
  127.     then
  128.         kill `cat /var/run/hurd-console.pid`
  129.     else
  130.         setupcon --force --save
  131.     fi
  132.     fi
  133. fi
  134.  
  135. # Automatically added by dh_installinit
  136. if [ -x "/etc/init.d/keyboard-setup" ]; then
  137.     update-rc.d keyboard-setup start 06 S . >/dev/null || exit $?
  138. fi
  139. # End automatically added section
  140. # Automatically added by dh_installinit
  141. if [ -x "/etc/init.d/console-setup" ]; then
  142.     update-rc.d console-setup start 49 S . >/dev/null || exit $?
  143. fi
  144. # End automatically added section
  145.  
  146.